<template>
  <div class="app-container home nhhcontent">
   <h1 class="nhh1">HairScan数据中心</h1>
    <el-row :gutter="20">
      <el-col :span="6"><div class="nhhtopitem  item1" >
        <div class="title">设备总数（台）</div>
        <div class="number">36894</div>
      </div></el-col>
      <el-col :span="6"><div  class="nhhtopitem  item2" >
        <div class="title">会员总数（人）</div>
        <div class="number">36894</div>
      </div></el-col>
      <el-col :span="6" ><div class="nhhtopitem  item3" >
        <div class="title">有效检测数（次）</div>
        <div class="number">36894</div>
      </div></el-col>
      <el-col :span="6" ><div class="nhhtopitem  item4" >
        <div class="title">累计收入（元）</div>
        <div class="number">36894</div>
      </div></el-col>
    </el-row>

    <el-row :gutter="20">

      <el-col :span="18">
        <el-row :gutter="20">
          <el-col :span="8">
            <div class="nhhtopitem2  item5" style="text-align: center" >
<!--              <div class="title2">数据折线图</div>-->
              <div ref="EcharOne" style="width: 100%;height:100%"></div>

            </div>
          </el-col>
          <el-col :span="16">
            <div class="nhhtopitem2  item5"style="text-align: center" >
<!--              <div class="title2">店铺会员数据折线图</div>-->
              <div ref="EcharRef" style="width: 100%;height:100%"></div>
            </div>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12"><div class="nhhtopitem3  item7" style="text-align: center" >
            <div class="title2">平均检测项</div>
            <div ref="Echar9" style="width: 100%;height:calc(100% - 30px)"></div>
          </div></el-col>
          <el-col :span="12" ><div class="nhhtopitem3  item8" style="text-align: center" >
            <div class="title2">数据分布图</div>
            <div ref="Echar10" style="width: 100%;height:calc(100% - 30px)"></div>
          </div></el-col>
        </el-row>
      </el-col>
      <el-col :span="6" >
        <div class="nhhtopitem6  item6" >
        <div class="title2">实时收入排行榜</div>
        <div ref="Echar8" style="width: 100%;height:calc(100% - 30px)"></div>
      </div></el-col>
    </el-row>


  </div>
</template>

<script setup name="Index">
import * as echarts from 'echarts'
const version = ref('1.0.8')
const EcharRef = ref();
const EcharOne = ref();//
const Echar8 = ref();//排行榜
const Echar9 = ref();//
const Echar10 = ref();//
const data = [];
//循环数据
for (let i = 0; i < 20; ++i) {
  data.push(Math.round(Math.random() * 200));
}
var option8 = {
  xAxis: {
    max: 'dataMax'
  },
  yAxis: {
    type: 'category',
    data: ['店铺1', '店铺2', '店铺3', '店铺4', '店铺5', '店铺6','店铺7','店铺8','店铺9','店铺10','店铺11','店铺12','店铺13','店铺14','店铺15','店铺16','店铺17','店铺18','店铺19','店铺20'],
    inverse: true,
    animationDuration: 300,
    animationDurationUpdate: 300,
    max: 10 // only the largest 3 bars will be displayed
  },
  series: [
    {
      realtimeSort: true,
      // name: 'X',
      type: 'bar',
      data: data,
      label: {
        show: true,
        position: 'right',
        valueAnimation: true
      }
    }
  ],
  legend: {
    show: true
  },
  animationDuration: 0,
  animationDurationUpdate: 3000,
  animationEasing: 'linear',
  animationEasingUpdate: 'linear'
};
function run() {
  for (var i = 0; i < data.length; ++i) {
    if (Math.random() > 0.9) {
      data[i] += Math.round(Math.random() * 2000);
    } else {
      data[i] += Math.round(Math.random() * 200);
    }
  }
  var myChart8 = echarts.init(Echar8.value);
  myChart8.setOption(option8,{
    series: [
      {
        type: 'bar',
        data
      }
    ]
  });
  window.addEventListener('resize', myChart8.resize);
}
setTimeout(function () {
  run();
}, 0);
setInterval(function () {
  run();
}, 3000);

function init(){
  var myChart = echarts.init(EcharRef.value);
  var myChart2 = echarts.init(EcharOne.value);
  var myChart9 = echarts.init(Echar9.value);
  var myChart10 = echarts.init(Echar10.value);
  //
 var option10= {
/*  title: {
    text: 'Proportion of Browsers',
        subtext: 'Fake Data',
        top: 10,
        left: 10
  },*/
  tooltip: {
    trigger: 'item'
  },
/*  legend: {
    type: 'scroll',
        bottom: 10,
        data: (function () {
      var list = [];
      for (var i = 1; i <= 28; i++) {
        list.push(i + 2000 + '');
      }
      return list;
    })()
  },*/
  visualMap: {
    top: 'middle',
        right: 10,
        color: ['red', 'yellow'],
        calculable: true
  },
  radar: {
    indicator: [
      { text: '头皮油脂', max: 400 },
      { text: '头发密度', max: 400 },
      { text: '头发粗细', max: 400 },
      { text: '头皮敏感', max: 400 },
      { text: '头皮弹性', max: 400 },
      { text: '角质头屑', max: 400 }
    ]
  },
  series: (function () {
    var series = [];
    for (var i = 1; i <= 28; i++) {
      series.push({
        type: 'radar',
        symbol: 'none',
        lineStyle: {
          width: 1
        },
        emphasis: {
          areaStyle: {
            color: 'rgba(0,250,0,0.3)'
          }
        },
        data: [
          {
            value: [
              (40 - i) * 10,
              (38 - i) * 4 + 60,
              i * 5 + 10,
              i * 9,
              (i * i) / 2
            ],
            name: i + 2000 + ''
          }
        ]
      });
    }
    return series;
  })()
};
  //9
  var option9 = {
    tooltip: {
      trigger: 'item'
    },
    legend: {
      top: '5%',
      left: 'center'
    },
    series: [
      {
        name: '检测项',
        type: 'pie',
        radius: ['40%', '70%'],
        avoidLabelOverlap: false,
        itemStyle: {
          borderRadius: 10,
          borderColor: '#fff',
          borderWidth: 2
        },
        label: {
          show: false,
          position: 'center'
        },
        emphasis: {
          label: {
            show: true,
            fontSize: 40,
            fontWeight: 'bold'
          }
        },
        labelLine: {
          show: false
        },
        data: [
          { value: 1048, name: '头皮油脂' },
          { value: 735, name: '头发密度' },
          { value: 580, name: '头发粗细' },
          { value: 484, name: '头皮敏感' },
          { value: 300, name: '角质头屑' },
          { value: 300, name: '头皮弹性' },
          { value: 300, name: '白发' }
        ]
      }
    ]
  };
  // 指定图表的配置项和数据
 var optionone = {

    tooltip: {},
    legend: {
      data: ['本周会员检测数']
    },
    xAxis: {
      data: ['周一', '周二', '周三', '周四', '周五', '周六','周日']
    },
    yAxis: {},
    series: [
      {
        name: '本周会员检测数',
        type: 'bar',
        data: [5, 20, 36, 10, 10, 20,60]
      }
    ]
  };
  var option = {
    title: {
      text: '店铺会员一周趋势'
    },
    tooltip: {
      trigger: 'axis',
      axisPointer: {
        type: 'cross',
        label: {
          backgroundColor: '#6a7985'
        }
      }
    },
    legend: {
      data: ['店铺1', '店铺2', '店铺3', '店铺4', '店铺5']
    },
    toolbox: {
      feature: {
        saveAsImage: {}
      }
    },
    grid: {
      left: '3%',
      right: '4%',
      bottom: '3%',
      containLabel: true
    },
    xAxis: [
      {
        type: 'category',
        boundaryGap: false,
        data: ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
      }
    ],
    yAxis: [
      {
        type: 'value'
      }
    ],
    series: [
      {
        name: '店铺1',
        type: 'line',
        stack: 'Total',
        areaStyle: {},
        emphasis: {
          focus: 'series'
        },
        data: [120, 132, 101, 134, 90, 230, 210]
      },
      {
        name: '店铺2',
        type: 'line',
        stack: 'Total',
        areaStyle: {},
        emphasis: {
          focus: 'series'
        },
        data: [220, 182, 191, 234, 290, 330, 310]
      },
      {
        name: '店铺3',
        type: 'line',
        stack: 'Total',
        areaStyle: {},
        emphasis: {
          focus: 'series'
        },
        data: [150, 232, 201, 154, 190, 330, 410]
      },
      {
        name: '店铺4',
        type: 'line',
        stack: 'Total',
        areaStyle: {},
        emphasis: {
          focus: 'series'
        },
        data: [320, 332, 301, 334, 390, 330, 320]
      },
      {
        name: '店铺5',
        type: 'line',
        stack: 'Total',
        label: {
          show: true,
          position: 'top'
        },
        areaStyle: {},
        emphasis: {
          focus: 'series'
        },
        data: [820, 932, 901, 934, 1290, 1330, 1320]
      }
    ]
  };
  // 使用刚指定的配置项和数据显示图表。
  myChart.setOption(option);
  myChart2.setOption(optionone);
  myChart9.setOption(option9);
  myChart10.setOption(option10);
  window.addEventListener('resize', myChart.resize);
  window.addEventListener('resize', myChart2.resize);
  window.addEventListener('resize', myChart9.resize);
  window.addEventListener('resize', myChart10.resize);
  // window.addEventListener('resize', myChart8.resize);
}

//初始化echarts:
onMounted(
    () => {
      init()
    }
)

</script>

<style scoped lang="scss">
/**/
.nhhcontent{
  background:#f1f0f1; height: calc(100vh - 90px) ; width: 100%;
}
.nhh1{text-align: center;font-family: "Microsoft YaHei";font-weight: 600;height: 60px;line-height: 60px;font-size: 1.5rem;margin: 0px;}
.nhhtopitem{height:9rem; background: #FFFFFF;border-radius: 7px; padding: 1.25rem;}
.item1{background:  linear-gradient(to top right, #5f71fc, #b87bfd);}
.item2{background:  linear-gradient(to top right, #3ea3f7, #98ccf8);}
.item3{background:  linear-gradient(to top right, #ff7e5f, #feb47b);}
.item4{background:  linear-gradient(to top right, #50d890, #91df58);}

.nhhtopitem2{height: 30vh; background: #FFFFFF;border-radius: 7px;margin-top: 1rem;padding: 1rem;}
.nhhtopitem3{height: 30vh; background: #FFFFFF;border-radius: 7px;margin-top: 1rem;padding: 1rem;}
.nhhtopitem6{height: 61.5vh; background: #FFFFFF;border-radius: 7px;margin-top: 1rem;padding: 1rem;}


.title{color: #FFFFFF;font-size: 1rem;font-weight: 600;height:2rem;}
.title2{color: #000000;font-size: 1rem;font-weight: 600;height:2rem;}

.number{color: #FFFFFF;font-size: 3rem;font-weight: 600; text-align: center}
/**/
.home {
  blockquote {
    padding: 10px 20px;
    margin: 0 0 20px;
    font-size: 17.5px;
    border-left: 5px solid #eee;
  }
  hr {
    margin-top: 20px;
    margin-bottom: 20px;
    border: 0;
    border-top: 1px solid #eee;
  }
  .col-item {
    margin-bottom: 20px;
  }

  ul {
    padding: 0;
    margin: 0;
  }

  font-family: "open sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 13px;
  color: #676a6c;
  overflow-x: hidden;

  ul {
    list-style-type: none;
  }

  h4 {
    margin-top: 0px;
  }

  h2 {
    margin-top: 10px;
    font-size: 26px;
    font-weight: 100;
  }

  p {
    margin-top: 10px;

    b {
      font-weight: 700;
    }
  }

  .update-log {
    ol {
      display: block;
      list-style-type: decimal;
      margin-block-start: 1em;
      margin-block-end: 1em;
      margin-inline-start: 0;
      margin-inline-end: 0;
      padding-inline-start: 40px;
    }
  }
}
</style>

